package com.cf.studiomanage.service.impl;

import com.cf.studiomanage.entity.User;
import com.cf.studiomanage.mapper.UserMapper;
import com.cf.studiomanage.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public boolean register(User user) {
        return userMapper.register(user) > 0;
    }

    @Override
    public User login(String account, String password) {
        return userMapper.login(account, account, password);
    }

    @Override
    public User getById(Long id) {
        return userMapper.getById(id);
    }

    @Override
    public boolean updateProfile(User user) {
        return userMapper.updateProfile(user) > 0;
    }

    @Override
    public boolean updatePassword(Long id, String newPassword) {
        return userMapper.updatePassword(id, newPassword) > 0;
    }
}
